<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>构造函数的参数</title>
  </head>
  <body>
    <script>
      // 固定参数应用场景
      //   function Car(name, price, size) {
      //     this.name = name;
      //     this.price = price;
      //     this.size = size;
      //   }
      //   var car1 = new Car("奔驰", "30w", "big");
      //   var car2 = new Car("50w", "奥迪", "small");
      //   console.log(car1);
      //   console.log(car2);

      // 对象类型参数

      function Car(obj) {
        this.name = obj.name;
        this.price = obj.price;
        this.size = obj.size;
      }
      var car1 = new Car({ name: "奔驰", price: "30w", size: "big" });
      var car2 = new Car({ price: "50w", name: "奥迪", size: "small" });
      console.log(car1);
      console.log(car2);
    </script>
  </body>
</html>
